/**
 * 
 */
package com.hz.winnie.demands.web.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hz.winnie.demands.common.DemandsConstants;
import com.hz.winnie.demands.pojo.User;
import com.hz.winnie.demands.service.DemandsService;

/**
 * @description 顶部controller
 * @author winnie
 * @date 2011-4-16
 * @version 1.0
 */
@Controller
@RequestMapping("/")
public class TopController {

    @Autowired
    private DemandsService demandsService;

    @Autowired
    private HttpSession session;

    @RequestMapping("/getTopMsgCount")
    @ResponseBody
    public String getTopMsgCount() {
	User demUser = (User) session
		.getAttribute(DemandsConstants.SESSION_KEY_USER);
	int userId = demUser.getId();

	String msgCount = demandsService.countIndexMsg(userId);
	return msgCount;
    }

    /**
     * top
     * 
     * @return
     */
    @RequestMapping("top_demands")
    public String topMessageDemands() {
	return "demand/search";
    }
}
